﻿using Microsoft.Extensions.DependencyInjection.Extensions;
using NetLogExtend.MSLogging.Abstractions;
using NLog.Fluent;
using NLog.Web;

namespace NetCoreStudy.NlogConfig
{
    public static class NlogBuild
    {

        public static WebApplicationBuilder NlogConfig(this WebApplicationBuilder builder)
        {
            //NLog:为依赖注入设置NLog
            builder.Logging.ClearProviders().AddNLog("LogConfig\\nlog.config");
            builder.Host.UseNLog();
         
            return builder;
        }

        /// <summary>
        /// 注册NLog日志操作
        /// </summary>
        /// <param name="services">服务集合</param>
        public static void AddNLog(this IServiceCollection services)
        {
            //services.TryAddScoped<ILogProviderFactory, Logs.NLog.NLogProviderFactory>();
            //services.TryAddSingleton<ILogFormat, ContentFormat>();
            //services.TryAddScoped<ILogContext, LogContext>();
            //services.TryAddScoped<Common.Logs.ILog, Log>();
        }
    }
}
